<template>
  <section class="i-head-slider"  >
    <swiper :options="swiperOption"
      ref="iHeaderSlider"
      :not-next-tick="swiperOption.notNextTick"
      @slideChange="slideChange">
      <!-- slides -->
      <swiper-slide class="item-swiper">
        <div class="item-m-swiper" :class="transformCls(0)">
          <div class="title">最高可借现金(元)</div>
          <div class="content">200,000.00</div>
          <div class="btn">查看我的额度</div>
        </div>
      </swiper-slide>
      <swiper-slide class="item-swiper">
        <div class="item-m-swiper" :class="transformCls(1)">
          <div class="title">迈出理财第一步，轻松享收益</div>
          <div class="content">
            <em>4.100%</em>
            <span class="small">百信智惠存</span>
          </div>
          <div class="btn">立 即 登 录</div>
        </div>
      </swiper-slide>
      <!-- Optional controls -->
    </swiper>
  </section>
</template>

<script>
import 'swiper/dist/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'

export default {
  name: 'i-head-slider',
  components: {
    swiper, swiperSlide
  },
  data () {
    return {
      swiperOption: {
        notNextTick: false
        // autoplay: true,
        // delay: 5000
      },
      currIndex: 0
    }
  },
  methods: {
    slideChange () {
      this.currIndex = this.$refs.iHeaderSlider.swiper.activeIndex
    },
    transformCls (trsIndex) {
      let preIndex = this.currIndex - 1
      let nextIndex = this.currIndex + 1
      if (trsIndex === preIndex) {
        return 'right-offset'
      } else if (trsIndex === nextIndex) {
        return 'left-offset'
      } else {
        return ''
      }
    }
  },
  computed: {

  }
}
</script>
<style lang="scss" scoped>
.i-head-slider {
  position: relative;
  height: 350px;
  overflow: hidden;
  background: linear-gradient(#E63A46,#D31F2C);
  border-bottom-width: 100px solid black;
  border-bottom: 120px solid #D31F2C;
  border-image: url('./bg_bottom.png') 0 20 100% 20 stretch;
  .item-swiper {
    width: 100%;
    box-sizing: border-box;
    padding: 30px 0px 20px 0px;
    .item-m-swiper {
      width: 620px;
      height: 300px;
      box-sizing: border-box;
      margin: 0 auto;
      text-align: center;
      border-radius: 10px;
      background-image: url('./bgimg.jpg');
      background-size: cover;
      padding: 40px 0px 0px 0px;
      transition: all .8s;
      .title {
        font-size: 30px;
        color: #C59FAC;
        margin-bottom: 30px;
      }
      .content {
        color: #fff;
        font-weight: 700;
        font-size: 55px;
        margin-bottom: 30px;
        .small {
          display: block;
          font-size: 24px;
          color: #C59FAC;
          margin-top: 6px;
        }
      }
      .btn {
        color: #FEF5F6;
        width: 380px;
        font-size: 30px;
        line-height: 60px;
        border: 1px solid #fff;
        border-radius: 60px;
        margin: 0 auto;
      }
    }
  }
  .left-offset {
    transform: translateX(-100px)
  }
  .right-offset {
    transform: translateX(100px)
  }
  // .bg-div {
  //   z-index: -1;
  //   position: absolute;
  //   left: 0;
  //   top: 0;
  //   right: 0;
  //   bottom: 0;
  //   background: linear-gradient(#E63A46,#D31F2C);
  //   .side-card {
  //     position: absolute;
  //     width: 620px;
  //     height: 300px;
  //     box-sizing: border-box;
  //     margin: 0 auto;
  //     text-align: center;
  //     background: green;
  //     border-radius: 10px;
  //     background-image: url('./bgimg.jpg');
  //     background-size: cover;
  //     padding: 40px 0px 0px 0px;
  //   }
  //   .left {
  //     top: 30px;
  //     left: -27.9rem;
  //     right: 0;
  //   }
  //   .right {
  //     top: 30px;
  //     right: -12.5rem;
  //   }
  // }
}
</style>
